//
//  BIDPopAnimation.m
//  EducationAssistant
//
//  Created by mal on 15/9/10.
//  Copyright (c) 2015年 cnsoft. All rights reserved.
//

#import "BIDPopAnimation.h"

@implementation BIDPopAnimation

- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext
{
    return 0.3f;
}

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
    UIViewController *desController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
    UIViewController *srcController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    [[transitionContext containerView] insertSubview:desController.view belowSubview:srcController.view];
    //desController.view.alpha = 0.0;
    
    [UIView animateWithDuration:[self transitionDuration:transitionContext]
                     animations:^{
                         //srcController.view.transform = CGAffineTransformMakeScale(-1.0, 1.0);
                         CGSize screenSize = [UIScreen mainScreen].bounds.size;
                         CGRect frame = srcController.view.frame;
                         frame.origin.y = screenSize.height;
                         srcController.view.frame = frame;
                         desController.view.alpha = 1.0;
                     }
                     completion:^(BOOL finished) {
                         //srcController.view.transform = CGAffineTransformIdentity;
                         //[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
                         [transitionContext completeTransition:YES];
                     }];
}

@end
